package com.polly.esphwevent.controller;

import com.polly.esphwevent.domain.HomeworkInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.Pattern;

/**
 * @author liqin@nd.com.cn
 * @version V1.0
 * @title: StuHomeworkController
 * @description: TODO(用一句话描述该文件做什么)
 * @date: 2019/2/28 15:17
 */
@RestController
@Validated
@Slf4j
public class StuHomeworkController {


    @RequestMapping(value = "/stu_homeworks", method = RequestMethod.GET)
    public HomeworkInfo getStudentHomeworkPage(
            @Min(value = 1, message = "LIMIT_LESS_THAN_MIN")
            @Max(value = 100, message = "LIMIT_GREATER_THAN_MAX")
            @RequestParam(value = "limit") int limit,
            @RequestParam(value = "offset") int offset,
            @Pattern(regexp="|todo|finished|archive", message="STU_HOMEWORK_SEARCH_TYPE_INVALID")
            @RequestParam(value = "orderby", required = false)String orderby
            )
    {
        if (offset < 0) {
            offset = 0;
        }

        return new HomeworkInfo();
    }
}
